package com.zzptc.llq.bdsjws.activities;

import android.os.Bundle;
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.RecyclerView;

import com.zzptc.llq.bdsjws.adapter.BbxAdapter;
import com.zzptc.llq.bdsjws.vo.Box;
import com.zzptc.llq.bdsjws.MyApplication;
import com.zzptc.llq.bdsjws.R;
import com.zzptc.llq.bdsjws.activities.base.BaseActivity;
import com.zzptc.llq.bdsjws.db.BoxDao;
import com.zzptc.llq.bdsjws.utils.DividerGridItemDecoration;

import java.util.List;

import butterknife.BindView;

public class BoxActivity extends BaseActivity {

    @BindView(R.id.rv_bbx)
    RecyclerView rvBbx;
    List<Box> list;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
    }

    @Override
    public int getContentXML() {
        return R.layout.activity_box;
    }

    @Override
    public void initData() {
        //到数据库中取数据出来  得到百宝箱Dao
        BoxDao boxDao = MyApplication.getDaoSession().getBoxDao();
        list = boxDao.loadAll();
        // LinearLayoutManager linearLayoutManager=new LinearLayoutManager(this);
        //用RecyclerView显示数据
        BbxAdapter bbxAdapter = new BbxAdapter(list);
      //  GridLayoutManager gridLayoutManager = new GridLayoutManager(this, 4);
        RecyclerView.LayoutManager layoutManager=new GridLayoutManager(this,4);//多肽   //垂直滑动

       // RecyclerView.LayoutManager layoutManager=(new StaggeredGridLayoutManager(4,StaggeredGridLayoutManager.HORIZONTAL));//平行滑动
        rvBbx.setLayoutManager(layoutManager);
       // rvBbx.addItemDecoration(new GridDivider(this));
        rvBbx.addItemDecoration(new DividerGridItemDecoration(this));
        rvBbx.setAdapter(bbxAdapter);
//
//        rvBbx.addOnItemTouchListener(new OnRecyclerItemClickListener(rvBbx){
//            @Override
//            public void onItemClick(RecyclerView.ViewHolder vh) {
//                super.onItemClick(vh);
//                Box box= list.get(vh.getPosition());
//                if(box.getName().equals("家人守护")){
//                    startActivity(new Intent(BoxActivity.this,FamilyProtectctivity.class));
//                }
//                else if(box.getName().equals("家人守护")){
//
//                }
//            }
//
//            @Override
//            public void onLongClick(RecyclerView.ViewHolder vh) {
//                super.onLongClick(vh);
//            }
//        });

    }

    @Override
    public void intView() {

    }
}
